/**
 * DataResponse - opensocial DataResponse to the DataRequest
 * 
 * @author Aaron Tong
 */
package com.nextgenapp.opensocial
{
	public class DataResponse
	{
		private var _responseItems:Object;
		private var _globalError:Boolean;
		private var _errorMesg:String;
		
		public function DataResponse(responseItems:Object, opt_globalError:Boolean, _eMesg:String=null)
		{
			_responseItems = responseItems ? responseItems : {};
			_globalError = opt_globalError;
			_errorMesg = _eMesg;
		}
		
		/**
		 * get - Gets the ResponseItem for the requested field. 
		 * @param key The key.
		 * @return  The requested response generated by the server.
		 * 
		 */		
		public function get(key:String):ResponseItem {
			return _responseItems[key];
		}
		
		/**
		 * RhadError - returns true if there was an error in fetching this data from the server. 
		 * @return True if there was an error; otherwise, false.
		 */		
		public function hadError():Boolean {
			return !!_globalError;
		}
		
		/**
		 * getErrorMessage - Gets the error message
		 * 
		 * @return - the error message
		 */
		 public function getErrorMessage():String {
		 	return _errorMesg;
		 }
	}
}